package com.list88zhu.android.room;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;
import android.content.Context;

@Database(entities = {User.class}, version = 1, exportSchema = false)
@TypeConverters({ConversionFactory.class})
public abstract class UserDatabase  extends RoomDatabase{

    public static UserDatabase getDefault(Context context){
        return buildDatabase(context);
    }

    private static UserDatabase buildDatabase(Context context){
        return Room.databaseBuilder(context.getApplicationContext(),
                UserDatabase.class,
                "User.db")
                .allowMainThreadQueries()
                .build();
    }

    public abstract UserDao getUserDao();
}
